 package cn.com.code;
 
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolEncoder;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
 public class MyEncoder
   implements ProtocolEncoder
 {
   public void dispose(IoSession arg0)
     throws Exception
   {
   }
 
   public void encode(IoSession arg0, Object arg1, ProtocolEncoderOutput arg2)
     throws Exception
   {
     byte[] array = (byte[])arg1;
     IoBuffer buff = IoBuffer.allocate(array.length, false);
     for (int i = 0; i < array.length; ++i)
     {
       buff.put(array[i]);
     }
 
     buff.flip();
     arg2.write(buff);
   }
 }